// 创建一个路由器，并暴露出去
 
 
//引入可能会用到的组件
import LoginPage from '@/components/LoginPage.vue'
import MainPage from '@/components/MainPage.vue'
import MyPage from '@/components/MyPage.vue'
import RegisterPage from '@/components/RegisterPage.vue'
import Torefs from '@/components/Torefs.vue'
import HelloWorldA from '@/components/HelloWorldA.vue'
import WelcomeItem from '@/components/WelcomeItem.vue'
import SoltFu from '@/components/SoltFu.vue'
import index from '@/layout/index.vue'
import { createRouter, createWebHistory} from 'vue-router';
import { reactive, ref } from 'vue'
import { defineStore } from 'pinia'
//const routes: any = staticRoutes.concat(defaultRoutes);


export const routes = [
    //{path:'/LoginPage', component: LoginPage},
    //{path:'/MainPage', component: MainPage},
    //{path:'/v1/api/test/get2', component: MyPage},
    //{path:'/RegisterPage', component: RegisterPage},
    //{path:'/HelloWorldA', component: HelloWorldA},
    //{path:'/WelcomeItem', component: WelcomeItem},
        {
            path:'/', 
            component: index
        },
        {
            path: '/index',
            name: 'index',
            component:  index,
            //redirect: '/index/MainPage',
            //路由嵌套
            children:[
                {path:'/index/LoginPage', component: LoginPage},
                {path:'/index/MainPage', component: MainPage},
                {path:'/index/MyPage', component: MyPage},
                {path:'/v1/api/test/get2',name:'get2', component: MyPage},  //http://127.0.0.1:5173/v1/api/test/get2?abc=10abca&age=2000
                {path:'/v1/api/test/get1/:id?',name:'get1', component: MyPage},  //http://localhost:8081/v1/api/test/get1/1111
                {path:'/index/RegisterPage', component: RegisterPage},
                {path:'/index/HelloWorldA', component: HelloWorldA},
                {path:'/index/SoltFu', component: SoltFu},
                {path:'/index/WelcomeItem', component: WelcomeItem},
                {path:'/index/Torefs', component: Torefs},
            ]
        },
        {
            path: "/svip", // http://localhost:5173/svip
            //redirect: "/vip" // 重定向
            redirect: { name:'get2', query: { abc: '重定向', age: '20' } } 
        }
]

//路由器
const router = createRouter({
    history: createWebHistory(),  
    routes
})





// export const router = defineStore('useRouter', () => {
//     //路由器
//     const router = createRouter({
//         history: createWebHistory(),  
//         routes
//     })
//     return {
//     router
//     }
//   })



  //暴露出去router
export default router